#!/usr/bin/python
# -*- coding: utf-8 -*-

from twisted.protocols import basic
from twisted.internet import epollreactor
try:
    epollreactor.install()
except:
    pass
from twisted.internet import reactor, protocol
from twisted.application import service, internet



class MyChat(basic.LineReceiver):
        def connectionMade(self):
            self.factory.clients.append(self)

        def connectionLost(self, reason):
            self.factory.clients.remove(self)

        def dataReceived(self, line):
                print line
                for c in self.factory.clients:
                    c.message(str(len(factory.clients))+'\r\n')

        def message(self, message):
            self.transport.write(message)




